<!-- <style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style> -->
<template src="./index.html"></template>
<script>
export default {
    mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.List],
    components: {},
    props: {
        // 使用者window实例 必定义
        appWindow: {
            type: Object,
            default: null,
        },
        // 接口列表
        apiConfig: {
            type: Object,
            default: {
                // 商品列表分页
                templateList: {
                    url: "mall-site-portal/decoration/list",
                    domain: "APP_MAIN_DOMAIN",
                },
            },
        },
        selected: {
            type: Object,
            default: null,
        },
    },
    data() {
        return {
            // 页面接口地址
            apiUrl: {
                list: null,
            },
            // 表格查询数据
            mixinList_tableSearchData: {
                templateType: 10,
            },
            templateList: [
                {
                    name: "微页面",
                    value: 10,
                    path: "/packSource/microPage/index",
                },
                {
                    name: "自定义表单",
                    value: -1,
                    path: "/packSource/customForm/index",
                },
            ],
            // 表格数据
            tableData: [],
        };
    },
    methods: {
        isSelect(item_) {
            let _url = "";
            let _item = this.getTemplateInfo();
            if (
                this.selected.path == _item.path &&
                item_.id ==
                    this.$vFN.Utils.optionalChain(this.selected, "query.id")
            ) {
                return true;
            } else {
                return false;
            }
        },
        // 初始化
        async init() {
            // 刷新表格数据，此方法扩展时可重写
            await this.mixinList_refreshData();
        },
        getTemplateInfo() {
            let _item = null;
            this.templateList.forEach((item) => {
                if (item.value == this.mixinList_tableSearchData.templateType) {
                    _item = item;
                }
            });
            return _item;
        },
        select(item_) {
            let _item = this.getTemplateInfo();
            this.$emit("change", {
                name: _item.name,
                templateType: this.mixinList_tableSearchData.templateType,
                id: item_.id,
                path: _item.path,
            });
        },
    },
    mounted() {
        console.error(this.apiConfig)
        this.apiUrl = {
            list: {
                url: this.apiConfig.templateList.url,
                domain: this.apiConfig.templateList.domain,
            },
        };
        this.init();
    },
    activated() {},
};
</script>